package com.itheima.twoshow;

public class Test {
        //二分查找最终版本


    public static int twoshow(int[]arr,int value){
        int left = 0 ;
        int right = arr.length-1;
        while(left <= right){
            int mid = (left + right)>>>1;
            if(arr[mid] == value){
                return mid;
            }else if(arr[mid] > value){
                right = mid - 1;
            }else{
                left = mid + 1;
            }
        }
        return -1;


    }
    public static void main(String[] args) {
            int[] arr = {1,2,3,4,5,6,7,8,9,10};
            int index = twoshow(arr, 5);
            System.out.println(index);



    }
}
